'use strict';

define({
    each (map, f) {
        for (var key in map) f(map[key], key);
    },

    mapv (m, f) {
        var result = {};
        this.each(m, (v, k) => result[k] = f(v, k));
        return result;
    },

    camelize: x => x.replace(/_./g, x => x.slice(1).toUpperCase()),

    throttle (callback, duration) {
        if (duration == null) duration = 500;
        var wait;
        return (...xs) => {
            if (wait) clearTimeout(wait);
            wait = setTimeout(() => callback(...xs), duration);
        };
    },
});

